<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="author" content="order by dede58.com"/>
    <title>online</title>
    <link rel="stylesheet" type="text/css" href="./css/style.css">
</head>
<body>
<!-- start header -->
<header>
    <div class="top center">
        <div class="left fl">
            <ul>
                <li><a href="" >首页</a></li>

                <div class="clear"></div>
            </ul>
        </div>
        <div id="not_login" class="right fr">
            <div class="gouwuche fr"><a href="./person_center/self_info.html">个人中心</a></div>
            <div class="fr">
                <ul>
                    <li><a href="./login.html" target="_blank">登录</a></li>
                    <li>|</li>
                    <li><a href="./register.html" target="_blank">注册</a></li>

                </ul>
            </div>
            <div class="clear"></div>
        </div>
        <div id="had_login" class="right fr">
            <div class="gouwuche fr"><a href="./person_center/self_info.html">个人中心</a></div>
            <div class="fr">
                <ul>
                    <li id="myProfile"></li>
                    <li><a id='userName' href="./person_center/self_info.html" target="_blank"></a></li>
                    <li>|</li>
                    <li><a href="./login.html" target="_blank">注销</a></li>

                </ul>
            </div>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
    </div>
</header>

<div class="danpin center">

    <div class="biaoti center" style="margin-top: 0px">onLine校园购物平台</div>
    <div style="background-color: #ffffff; width:100%;height: 70px;">
        <div class="banner_x center">
            <div class="nav fl">
                <ul>

                </ul>
            </div>
            <div class="search fr" style="margin-top: 0px">
                    <div class="text fl" style="margin-top: 0px">
                        <input type="text" id="searchValue" class="shuru" style="margin-top: 0px" placeholder="online校园交易平台">
                    </div>
                    <div class="submit fl" style="margin-top: 0px">
                        <input onclick="mySearch()" type="submit" class="sousuo" style="margin-top: 0px" value="搜索">
                    </div>
                    <div class="clear"></div>
                <div class="clear"></div>
            </div>
        </div>
    </div>
    <div>
    <div id="lis" class="main center" style="padding-top: 30px">

    </div>
<div>
    <!--<form action="" method="post">-->
        <!--<div class="text fl">-->
            <!--<input type="text" class="shuru" placeholder="">-->
        <!--</div>-->
        <!--<div class="submit fl">-->
            <!--<input type="submit" class="sousuo" value="搜索"/>-->
        <!--</div>-->
        <!--<div class="clear"></div>-->
    <!--</form>-->
</div>

<footer class="myfooter">
    <span >copyright @ 2018 online</span>
</footer>
</body>

<script src="js/crabapple.js" type="text/javascript"></script>
<script>
if(getCookie('userId')!=null){
    document.getElementById('userName').innerText=getCookie('userName')
    document.getElementById('not_login').style.display='none'
    document.getElementById("myProfile").innerHTML="<img style='width: 25px;height: 25px;border-radius:25px;vertical-align: middle;' src=\""+prime_url+"profile\\"+getCookie('userId')+".jpg"+"\">"
}
else
    document.getElementById('had_login').style.display='none'
getGoods()
function getGoods() {
    let xmlhttplogin = new XMLHttpRequest();
    xmlhttplogin.onreadystatechange = function () {
        if (xmlhttplogin.readyState == 4 && xmlhttplogin.status == 200) {
            let re = JSON.parse(xmlhttplogin.responseText);

            if (re.success == true) {
                console.log(re)
                let content=''
                for(i in re.shopList){
                    let item=re.shopList[i]
                    console.log(i)
                    content+=getIndexGoods(item.shopId,item.shopName,item.shopInfo)

                }

                document.getElementById('lis').innerHTML=content

            }
            else alert(re.errMsg)
        }
    }
    xmlhttplogin.open("GET", prime_url + 'shop/listrandomshops', true);
    xmlhttplogin.setRequestHeader('Content-Type', 'application/json')
    xmlhttplogin.send();
}

function mySearch(){
    let item=document.getElementById('searchValue').value
    let xmlhttplogin = new XMLHttpRequest();
    xmlhttplogin.onreadystatechange = function () {
        if (xmlhttplogin.readyState == 4 && xmlhttplogin.status == 200) {
            let re = JSON.parse(xmlhttplogin.responseText);

            if (re.success == true) {
                console.log(re)
                let content=''
                for(i in re.shopList){
                    let item=re.shopList[i]
                    console.log(i)
                    content+=getIndexGoods(item.shopId,item.shopName,item.shopInfo)
                }
                document.getElementById('lis').innerHTML=content
            }
            else alert(re.errMsg)
        }
    }
    xmlhttplogin.open("GET", prime_url + 'shop/listshopspageinfo?shopName='+item, true);
    xmlhttplogin.setRequestHeader('Content-Type', 'application/json')
    xmlhttplogin.send();
}

</script>
</html>